#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
union Us
{
	int  a;
	char s;

};
int main1()
{
	union Us u = { 0 };
	u.a = 0x11223344;
	u.s = 0x33;



	return 0; 
}


int main2()
{
	int* pa = (int*)malloc(sizeof(int) * 10);
	if (pa == NULL)
	{
		perror("malloc ");
		exit(1);
	}
	int i = 0; 
	for (i = 0; i < 10; i++)
	{
		*(pa + i) = i + 1;

	}

	return 0; 
}

int main4()
{
	int* pa = (int*)malloc(sizeof(int) * 10);
	if (pa == NULL)
	{
		perror("malloc ");
		exit(1);
	}
	
	free(pa);
	pa = NULL;
	return 0;
}
int main6()
{
	int* pa = (int*)calloc(10,sizeof(int));
	if (pa == NULL)
	{
		perror("calloc ");
		exit(1);
	}
	int i = 0; 
	for (i = 0; i < 10; i++)
	{
		printf("%d ", pa[i]);

	}
	free(pa);
	pa = NULL;
	return 0;
}
int main()
{
	int* p = (int*)realloc(10, sizeof(int));
	if (p == NULL)
	{
		perror("realloc ");
		return 1;
	}

	int i = 0; 
	for (i = 0; i < 10; i++)
	{
		printf("%d ", p[i]);
	}
	int* ptr = (int*)realloc(p, sizeof(int)* 20);
	if (ptr != NULL)
	{
		p = ptr;
	}
	free(p);
	p = NULL;
	return 0; 
}
